<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    #container {
      width: 100%;
      height: 200px;
      line-height: 200px;
      text-align: center;
      color: orange;
      background-color: #444;
      font-size: 30px;
    }
  </style>
</head>

<body>
  <div id="container"></div>
  <button id="btn">取消防抖</button>
  <script src=" https://cdn.bootcdn.net/ajax/libs/underscore.js/1.9.1/underscore.js"></script>
  <script src="./实现debounce方法.js"></script>
  <script>
    let count = 0
    let container = document.querySelector('#container')
    let btn = document.querySelector('#btn')
    function doSomeThing(event) {
      console.log(event);
      // this指向要手动更改
      console.log(this)
      container.innerHTML = count++
      // 一些网络请求 可以有返回结果
      return 'response'
    }
    let doSome = debounce(doSomeThing, 1000)
    btn.onclick = function () {
      doSome.cancel()
    }
    // 点号左边是对象 （）左边是函数
    container.onmousemove = doSome
  </script>
</body>

</html>